/* 
 * File:   onewire.h
 * Author: Marcel
 *
 * Created on 19. Juli 2012, 02:54
 */

#ifndef ONEWIRE_H
#define	ONEWIRE_H

#define DQ_DIN  PORTAbits.RA0
#define DQ_DOUT LATAbits.LATA0
#define DQ_DIR  TRISAbits.TRISA0
#define INPUT   1
#define OUTPUT  0
 
#define DQ_LOW      {DQ_DOUT = 0; DQ_DIR = OUTPUT;}
#define DQ_WHIGH    {DQ_DOUT = 0; DQ_DIR = INPUT;}
#define DQ_SHIGH    {DQ_DOUT = 1; DQ_DIR = OUTPUT;}

void ow_init(void);
void ow_reset(void);
void ow_write(unsigned char data);
unsigned char ow_read(void);
void ow_read_rom(void);
unsigned char ow_crc_calc(unsigned char buff[], unsigned char num_vals);
void ow_temp_raw(unsigned char* data);
int ow_temp(unsigned char* raw);
unsigned int ow_work(void);
void ow_puttemp(unsigned int temp_raw, unsigned char pos_x, unsigned char pos_y);

#endif	/* ONEWIRE_H */

